<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:rich="http://richfaces.org/rich" xmlns:a4j="http://richfaces.org/a4j">
	<div id="body">
		<h:form>
			<div id="container">
				<div id="navi">
					<span>
						<h:graphicImage value="/resources/image/searchicon.jpg" alt="image" width="15" height="15"/>
						<h:outputLink value="index.xhtml" class="navi_button">Back to Entry</h:outputLink>
					</span>
					|
					<span>
						<h:graphicImage value="/resources/image/searchicon.jpg" alt="image" width="15" height="15"/>
						<h:outputLink value="browse.xhtml" class="navi_button">Browse</h:outputLink>
					</span>
				</div>
				<div id="searchInfo" >
					<div class="content_head">
						<span>Purchase Search</span>
					</div>
					<div class="content_body" >
						<div class="searchorder_option">
						<h:panelGrid columns="2">
							<h:outputText id="purchaseNumber" value="Purchase number" />
							<h:inputText value="#{searchPurchase.currentPurchaseSearchNumber}" />
							<h:outputText id="buyerSurname" value="Buyer surname" />
							<h:inputText value="#{searchPurchase.currentPurchaseSearchSurname}" />
							<h:outputText value=""/>
						    <a4j:commandButton actionListener="#{searchPurchase.search()}" value="Search" render="@form" style="list-style-type: none"/>
					   </h:panelGrid>
						</div>
					</div>
				</div>
				<div id="searchResult">
					<div class="content_head">
						<span>Purchase Information</span>
					</div>
					<!--<c:set var="total" value="#{0}"/>-->
					<div class="content_body">
						<rich:dataTable value="#{searchPurchase.currentPurchase.products}" var="purchaseProduct" rows="10" styleClass="data" rendered="#{searchPurchase.currentPurchase != null}">
							<rich:column style="width: 20%">
								<f:facet name="header">
									Product Category
								</f:facet>
								<h:outputText value="#{purchaseProduct.product.category.name}" />
							</rich:column>
							<rich:column style="width: 20%">
								<f:facet name="header">
									Product code
								</f:facet>
								<h:outputText value="#{purchaseProduct.product.id}" />
							</rich:column>
							<rich:column style="width: 20%">
								<f:facet name="header">
									Product description
								</f:facet>
								<h:outputText value="#{purchaseProduct.product.name}" />
							</rich:column>
							<rich:column style="width: 20%">
								<f:facet name="header">
									Product quantity
								</f:facet>
								<h:outputText value="#{purchaseProduct.quantity}" />
							</rich:column>
							<rich:column style="width: 10%">
								<f:facet name="header">
									Total
								</f:facet>
								AU$ <h:outputText value="#{purchaseProduct.price}" />
							</rich:column>
							<rich:column style="width: 10%">
								<f:facet name="header">
									Purchase status code
								</f:facet>
								<h:outputText value="#{purchaseProduct.purchase.status}" />
							</rich:column>
						</rich:dataTable>
						<div class="total"><h:outputText value="Total: AU$ #{searchPurchase.currentPurchase.total}" rendered="#{searchPurchase.currentPurchase != null}" /></div>
						<h:outputText value="No purchase is found yet." rendered="#{searchPurchase.currentPurchase == null}" />
					</div>
					<rich:popupPanel id="productPanel" modal="true" autosized="false" resizeable="false" onmaskclick="#{rich:component('popup')}.hide()">
						<f:facet name="header">
							<h:outputText value="Product information page" />
						</f:facet>
						Add image, category, price, qty, description.
						<h:commandButton value="Add to cart" onclick="#{rich:component('productPanel')}.hide()">			
						</h:commandButton>	
					</rich:popupPanel>
				</div>	
			</div>
		</h:form>
	</div>
</ui:composition>
